<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>ftgenonce</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="ftgen.html" title="ftgen" />
    <link rel="next" href="ftgentmp.html" title="ftgentmp" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">ftgenonce</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="ftgen.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="ftgentmp.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="ftgenonce"></a>
      <div class="titlepage"></div>
      <a id="Indexftgenonce" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">ftgenonce</span>
        </h2>
        <p>ftgenonce — 
       Generate a function table from within an instrument definition, without duplication of data.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp111619568"></a>
        <h2>Description</h2>
        <p>
      Enables the creation of function tables entirely inside 
      instrument definitions, without any duplication of data.
    </p>
        <p>
      The ftgenonce opcode is designed to simplify writing instrument definitions 
      that can be re-used in different orchestras simply by #including them
      and plugging them into some output instrument. There is no need to define 
      function tables either in the score, or in the orchestra header.
    </p>
        <p>
      The ftgenonce opcode is similar to ftgentmp, and has identical arguments.
      However, function tables are neither duplicated nor deleted. Instead, 
      all of the arguments to the opcode are concatenated to form the key to a 
      lookup table that points to the function table number. Thus, every request 
      to ftgenonce with the same arguments receives the same instance of the 
      function table data. Every change in the value of any ftgenonce argument
      causes the creation of a new function table.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp111662928"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ifno <span class="command"><strong>ftgenonce</strong></span> ip1, ip2dummy, isize, igen, iarga, iargb, ...</pre>
      </div>
      <div class="refsect1">
        <a id="idp111665104"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifno</em></span> --  an automatically
      assigned table number.
    </p>
        <p>
      <span class="emphasis"><em>ip1</em></span> -- the number of the table to be
      generated or 0 if the number is to be assigned.
    </p>
        <p>

    <span class="emphasis"><em>ip2dummy</em></span> -- ignored.
    </p>
        <p>
      <span class="emphasis"><em>isize</em></span> -- table size. Corresponds to p3 of the score <span class="emphasis"><em>f statement</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>igen</em></span> -- function table <span class="emphasis"><em>GEN</em></span> routine. Corresponds to p4 of the score <span class="emphasis"><em>f statement</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>iarga, iargb, ...</em></span> -- function table arguments. Correspond to p5 through p<span class="emphasis"><em>n</em></span> of the score <span class="emphasis"><em>f statement</em></span>.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>Csound was originally designed to support tables with power of two sizes only. Though this has changed in recent versions (you can use any size by using a negative number), many opcodes will not accept them.</p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp111674688"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the ftgenonce opcode. It uses the file <a class="ulink" href="examples/ftgenonce.csd" target="_top"><em class="citetitle">ftgenonce.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp111676464"></a>
          <p class="title">
            <strong>Example 333. Example of the ftgenonce opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o ftgenonce.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
 

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1 
<span class="comment">; Use ftgenonce instead of ftgen, ftgentmp, or f statement</span>
iHz	<span class="op">=</span> p4
isine	<span class="opc">ftgenonce</span> 0, 0, 1024, 10, 1 
aoscili	<span class="opc">pluck</span> .7, iHz, 100, isine, 1 
aadsr 	<span class="opc">adsr</span> 0.015, 0.07, 0.6, 0.3
asig 	<span class="op">=</span> aoscili <span class="op">*</span> aadsr
        <span class="opc">outs</span> asig, asig
<span class="oblock">endin</span> 

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 

<span class="stamnt">i</span> 1 0 1 220 
<span class="stamnt">i</span> 1 2 1 261 
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp111678432"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Authors: Michael Gogins</td>
          </tr>
          <tr>
            <td>2009</td>
          </tr>
        </table>
        <p>
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="ftgen.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="ftgentmp.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">ftgen </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ftgentmp</td>
        </tr>
      </table>
    </div>
  </body>
</html>
